package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    //累计用户数
    @Select("select sum(num_registered) from tb_analysis_by_day")
    Long sumCumulativeUsers();

    @Select("select sum(num_active) from tb_analysis_by_day where record_date between #{beginDate} and #{today}")
    Long selectActiveByTime(@Param("beginDate") String beginDate,@Param("today") String today);


    //新增用户
    @Select("select sum(num_registered) from tb_analysis_by_day where record_date=#{date1}")
    Integer findNumRegistered(String date1);

    //活跃用户
    @Select("select sum(num_active) from tb_analysis_by_day where record_date=#{date1}")
    Integer findNumActive(String date1);

    //次留存率
    @Select("select sum(num_retention1d) from tb_analysis_by_day where record_date=#{date1}")
    Integer findNumRetention1d(String date1);
}